<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

    <link href="style/css.css" rel="stylesheet" type="text/css" />
    <link href="style/gysqy.css" rel="stylesheet" type="text/css" />
	<link href="style/right.css" rel="stylesheet" type="text/css" />
	<link href="style/cpfl.css" rel="stylesheet" type="text/css" />
	<link href="style/clxq.css" rel="stylesheet" type="text/css" />
    <script src="common/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="common/json2.js" type="text/javascript"></script>
    <script src="common/jsmart.js" type="text/javascript"></script>
        
    <script src="script/app.js" type="text/javascript"></script>
 
	<script id="category" type="text/x-jsmart-tmpl">  
	{foreach $first as $name => $firstcategory}
		<li class="normal">
			<div class="left_show_title">
				<a href="/Search/Products?code=01" title="{$firstcategory.value}">{$firstcategory.value}</a></div>
			<div class="left_show_wz">
				{foreach $firstcategory.second as $name => $secondcategory}
				<a href="/Search/Products?code=0101" title="{$secondcategory.value}">{$secondcategory.value}</a>
				{/foreach}
			</div>
		</li>
	{/foreach}
    </script>
    

</head>
<body>
<center> 
    <div id="box">
        <div id="main">
            <div class="left fl">
                <!-- left_menu -->
                <div class="left_menu">
                    <div class="left_menu_left fl">
                    </div>
                    <div class="left_menu_center fl">
                        <div class="left_menu_center_bt">
                            <div class="fl">
                                产品分类</div>
                            <div class="fr left_menu_more">
                            </div>
                        </div>
                    </div>
                    <div class="left_menu_right fr">
                    </div>
                    <!-- left_menu_nr -->
                    <div class="left_show_nr nf">
                        <ul id="categorylist">

                        </ul>
                    </div>
                </div>
            </div>           
        </div>
    </div>
        <script type="text/javascript">
	
		$(document).ready(
			function () {
				$.ajax({
					url: 'service/_view/getCategory?reduce=false',
					type: 'GET',
					dataType: 'json',
					success:function(data){
						var tpl = new jSmart(document.getElementById('category').innerHTML);
						var category = new Array();
						category.first = $.grep(data.rows, function(value){
							return value.key[1] == null;	
						});
						
						for (var index in category.first)
						{
							var id = category.first[index].key[0];
							category.first[index].second = $.grep(data.rows, function(value){
								return value.key[0] == id;
							});
							var temp = category.first[index].second;
						}
						
						
						var res = tpl.fetch(category);
						$("#categorylist").html(res);
					}
				});			
			}
		);
	</script>

</center>
</body>
</html>